package com.platform.usercenter.domain.vo;


import cn.hutool.core.collection.CollectionUtil;
import com.platform.usercenter.service.TreeAdapter;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: 可乐
 * @Description:
 * @CreateTime: 2023-10-19  13:41
 */
@Data
public class SysOrgDeptTreeVO  implements TreeAdapter {



	/** 组织ID */
	private Long orgId;

	/** 组织名称 */
	private String orgName;

	/**
	 * 父节点
	 */
	private Long parentId;


	/**
	 * 子组织列表
	 */
	private List<SysOrgDeptTreeVO> children;


	/**
	 * 部门列表
	 */
	private List<SysOrganizationDeptVO> sysOrganizationDepts;

	@Override
	public Long getTreeCurrentId( ) {
		return orgId;
	}

	@Override
	public Long getTreeParentId( ) {
		return parentId;
	}

	@Override
	public <T> void setTreeChildren(List<TreeAdapter> list, Class<T> clazz) {
		if (this.getClass().isAssignableFrom(clazz) && CollectionUtil.isNotEmpty(list)) {
			List<SysOrgDeptTreeVO> collect = list.stream().map(SysOrgDeptTreeVO.class::cast).collect( Collectors.toList());
			this.setChildren(collect);
		}
	}
}
